var z = 123;
function testObj() {
  var person = new Object();
    person.firstname = "Bill";
    person.lastname = "Gates";
    person.age = 56;
    person.eyecolor= "blue";
    var message = "Hello World";

    var x = message.length;
    var y = message.toUpperCase();
    document.write(person.firstname + " is " + person.age +" years old."
        + "<br>" + x
    +"<br>" +y);
}

function testVar(name, job) {
    alert("welcome " + name + ",this " + job);
}
function returnVar() {
    var x = 5;
    return x;
}

function returnTest() {
    document.write(returnVar() + z);
}

function weekShow() {
    var day = new Date().getDay();
    var x;
    switch (day){
        case 0:
            x ="Today is Sunday";
            break;
        case 1:
            x = "Today is Monday";
            break;
        case 2:
            x = "Today is Tuesday";
            break;
        case 3:
            x = "Today is Wednesday";
            break;
        case 4:
            x = "Today is Thursday";
            break;
        case 5:
            x = "Today is Friday";
            break;
        default:
            break;
    }
    document.write(x);
}
// for in 循环遍历对象的属性
function forInTest() {
    var person = {fname:"John",lname:"Doe",age:25};
    var txt = "1";
    for (var x in person){
        txt += person[x] + "<br>";
    }
    document.write(txt);
}

function forBreak() {
    var x = 123;
    for (var i = 0; i < 10; i ++){
        if (i == 3){
            break;
        }
        x += "the number is " + i + "<br>";
    }
    document.write(x);
}

function breakLable() {
    var cars = ["Bmw","Audi","FOrd"];
    list:{
        document.write(cars[0] + "<br>");
        document.write(cars[1] + "<br>");
        break list;
        document.write(cars[2] + "<br>");
    }
}

function errorTest() {
    var txt = "";
    try {
        addlert("welcome test");
    }catch (err){
        txt = "error: " + err.message +"\n";
        alert(txt);
    }

}

function testAttrs() {
    document.getElementById("imge").src = "../test2.jpg";
}
